package com.listener;

import com.event.DemoEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * author:houkai
 * Date: 2017/9/25
 * describe:监听器  注意需要注入
 */
public class DemoListener implements ApplicationListener {
    public void onApplicationEvent(ApplicationEvent applicationEvent) {

        if(applicationEvent instanceof DemoEvent){
             DemoEvent demoEvent = (DemoEvent) applicationEvent;

             System.out.println("添加事件触发"+demoEvent.getStuName());    //可以在监听器中调用别的事务处理代码
        }
    }
}
